﻿using FirstFloor.ModernUI.Windows.Controls;
using System.Windows;
using System.Windows.Controls;
using Vtron.LEDCorrective.Core;
using Vtron.LEDCorrective.Domain.LEDSender;

namespace Vtron.LEDCorrective.Pages
{
    /// <summary>
    /// SenderControl.xaml 的交互逻辑
    /// </summary>
    public partial class SenderControl : UserControl
    {
        public SenderControl()
        {
            InitializeComponent();
            Loaded += SenderControl_Loaded;
        }

        private void SenderControl_Loaded(object sender, RoutedEventArgs e)
        {
            CorrectiveEngine correctiveEngine = CorrectiveEngine.Instance;
            SCP_WALLS_T wall = correctiveEngine.GetWall();
            if (wall.wallNum == 1)
            {
                correctiveEngine.ResolWidth = (int)wall.wall[0].resol.width;
                correctiveEngine.ResolHeight = (int)wall.wall[0].resol.height;
                correctiveEngine.ScaleColumn = (int)wall.wall[0].scale.col;
                correctiveEngine.ScaleRow = (int)wall.wall[0].scale.row;

                correctiveEngine.Scp_wall = wall.wall[0];

                adjustDots_CheckBox.IsChecked = CorrectiveEngine.Instance.GetAdjustDots();
            }
            else if (wall.wallNum == 0)
            {
                ModernDialog.ShowMessage("未分配默认墙体，请分配后再校正！", "提示", MessageBoxButton.OK);
                return;
            }
            else if (wall.wallNum > 1)
            {
                ModernDialog.ShowMessage("系统错误，默认墙体大于一个！", "错误", MessageBoxButton.OK);
                return;
            }
        }

        private void adjustDots_CheckBox_Click(object sender, RoutedEventArgs e)
        {
            CorrectiveEngine correctiveEngine = CorrectiveEngine.Instance;

            correctiveEngine.SetAdjustDots((bool)adjustDots_CheckBox.IsChecked);
        }
    }
}
